﻿// *************************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2018. All rights reserved.
//  
// Web: http://www.scichart.com
//   Support: support@scichart.com
//   Sales:   sales@scichart.com
// 
// CustomFlipModifier.cs is part of SCICHART®, High Performance Scientific Charts
// For full terms and conditions of the license, see http://www.scichart.com/scichart-eula/
// 
// This source code is protected by international copyright law. Unauthorized
// reproduction, reverse-engineering, or distribution of all or any portion of
// this source code is strictly prohibited.
// 
// This source code contains confidential and proprietary trade secrets of
// SciChart Ltd., and should at no time be copied, transferred, sold,
// distributed or made available without express written permission.
// *************************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using SciChart.Charting.ChartModifiers;
using SciChart.Charting.Common.Helpers;
using SciChart.Charting.Model;

namespace SciChart.Examples.ExternalDependencies.Controls.SciChartInteractionToolbar.CustomModifiers
{
    public class CustomFlipModifier : ChartModifierBase
    {
        public ICommand FlipXAxis
        {
            get
            {
                return new ActionCommand(() =>
                {
                    if (ParentSurface != null)
                    {
                        FlipAxes(ParentSurface.XAxes);
                    }

                });
            }
        }

        public ICommand FlipYAxis
        {
            get
            {
                return new ActionCommand(() =>
                {
                    if (ParentSurface != null)
                    {
                        FlipAxes(ParentSurface.YAxes);
                    }
                });
            }
        }

        public void FlipAxes(AxisCollection axes)
        {
            using (ParentSurface.SuspendUpdates())
            {
                foreach (var axis in axes)
                    axis.FlipCoordinates = !axis.FlipCoordinates;
            }
        }
    }
}
